package cn.tedu.online.day04;

import java.util.*;

public class LambdaDemo3 {
    public static void main(String[] args) {
        System.out.println("输入字符串");
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] chars = str.toCharArray();

        Map<Character,Integer> map = new HashMap<>();

        for (char c : chars){
            if (map.containsKey(c)){
                map.put(c,map.get(c)+1);
            }else{
                map.put(c,1);
            }
        }

        List<Map.Entry<Character,Integer>> list = new ArrayList<>(map.entrySet());
        list.sort((o1, o2) ->
                o2.getValue().compareTo(o1.getValue()));
        list.forEach(entry -> System.out.println(entry));

        


    }
}
